# !/usr/bin/env python
# -*- coding:utf-8 -*-
from modelDb.baseModel import baseModel
import pymysql

class recordModel(baseModel):
    def __init__(self):
        super(recordModel, self).__init__()
        self._table = "record"

    #====================================================
    # 通过id查找客源数据
    #====================================================
    def findDsb(self):
        cursor = self.conn.cursor(cursor=pymysql.cursors.DictCursor)

        sql = "select * from record where name = 'dsp'"
        cursor.execute(sql)
        result = cursor.fetchone()

        cursor.close()
        return result


    #====================================================
    # 跟新etl清洗的数据
    #====================================================
    def updateDsb(self, update_id):
        if not update_id: return False
        cursor = self.conn.cursor()

        sql = "update record set update_id=%d where name='dsp'" % (update_id)
        effect_row = cursor.execute(sql)
        self.conn.commit()

        # 关闭游标
        cursor.close()
        return effect_row
